package com.study.blogsearchconsumer.rabbitMQ;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * mq发送
 */
@Component
public class MqProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMsg(String exchange,String routingKey,String content) {
        rabbitTemplate.convertAndSend(exchange, routingKey, content, new CorrelationData(UUID.randomUUID().toString()));
    }
}
